/*
关系运算符重载
作用： 重载关系运算符，可以让两个自定义类型对象进行对比操作

Created by ZXF on 2025/5/9.
*/

#include <iostream>
using namespace std;


class Person {
public:
    Person(string name, int age) {
        this->m_Name = name;
        this->m_Age = age;
    };

    bool operator==(Person &p) {
        if (this->m_Name == p.m_Name && this->m_Age == p.m_Age) {
            return true;
        } else {
            return false;
        }
    }

    bool operator!=(Person &p) {
        if (this->m_Name == p.m_Name && this->m_Age == p.m_Age) {
            return false;
        } else {
            return true;
        }
    }

    string m_Name;
    int m_Age;
};

void testOut() {
    // int a = 0;
    // int b = 0;
    Person a("孙悟空", 18);
    Person b("孙悟空", 18);
    if (a == b) {
        cout << "a和b相等" << endl;
    } else {
        cout << "a和b不相等" << endl;
    }
    if (a != b) {
        cout << "a和b不相等" << endl;
    } else {
        cout << "a和b相等" << endl;
    }
}

int main() {
    testOut();
    return 0;
}
